import { Observer } from 'mobx-vue'
import { Component, Vue } from 'vue-property-decorator'
import { getPaeList } from 'src/utils/axios'
import PaeAdd from 'src/views/pae/components/pae-add/pae-add.vue'
require('./pae.scss')
@Observer
@Component({
    components:{
        PaeAdd
    }
})
export default class ZtCommunity extends Vue {
    //添加宣教弹出层
    isAdd: boolean = false
    name: any = '';
    page: number = 1;
    count: number = 0;//总页数
    tableData: any = [];
    queryForm: any = {
        name: ''
    }
    tableColums: any = [
        {
            title: '#ID',
            key: 'id'
        },
        {
            title: '标题',
            key: 'title'
        },
        {
            title: '宣教类别',
            key: 'class_title'
        },
        {
            title: '媒体类型',
            slot: 'media_type'
        },
        {
            title: 'URL地址',
            slot: 'content'
        },
        {
            align: 'center',
            title: '操作',
            slot: 'operation'
        }
    ]

    mounted() {
        let vm: any = this;
        vm.getList(0);
    }
    // 添加社区
    digAdd() {
        let vm = this
        vm.isAdd = false
        vm.getList(vm.page)
    }
    async getList(page) {
        let vm: any = this;
        let params: any = {
            "filter": {

            },
            "range": page == 0 ? [0, 10] : [page * 10 + 1, 10],
            "sort": []
        }

        let out: any = await getPaeList(params);
        if (!out.status) {
            if (!out.data.list.length && page > 1) {
                vm.getList(page - 1)
                return
            }
            vm.page = page
            vm.count = out.data.total;
            vm.tableData = out.data.list
            console.log('vm.tableData', vm.tableData)
        } else {
            vm.$Message.error(await vm.$api.xerror(out.status));
        }
    }
    //改变页码
    async changePage(index) {
        this.getList(index)
    }

}
